Tidy3D Electromagnetic Solver

Tidy3D Electromagnetic Solver#

https://img.shields.io/badge/pypi-tidy3d-blue?style=for-the-badge https://img.shields.io/pypi/v/tidy3d.svg?style=for-the-badge https://readthedocs.com/projects/flexcompute-tidy3ddocumentation/badge/?version=latest&style=for-the-badge https://img.shields.io/github/actions/workflow/status/flexcompute/tidy3d/run_tests.yml?style=for-the-badge https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/daquinteroflex/4702549574741e87deaadba436218ebd/raw/tidy3d_extension.json https://img.shields.io/github/license/flexcompute/tidy3d?style=for-the-badge https://img.shields.io/badge/Demo-Notebooks-9647AE?style=for-the-badge https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge

Tidy3D is a software package for solving extremely large electrodynamics problems using the finite-difference time-domain (FDTD) method. It can be controlled through either an open source python package or a web-based graphical user interface.

This python API allows you to:

  • Programmatically define FDTD simulations.

  • Submit and manage simulations running on Flexcomputeโ€™s servers.

  • Download and postprocess the results from the simulations.

Get Started#

Install the latest stable python library tidy3d for creating, managing, and postprocessing simulations with

pip install --user tidy3d

Next, configure your tidy3d package with the API key from your account.

Get your free API key

tidy3d configure --apikey=XXX

And enter your API key when prompted.

For more detailed installation instructions, see this page.

Quick Example#

Start running simulations with just a few lines of code. Run this sample code to simulate a 3D dielectric box in Tidy3D and plot the corresponding field pattern.

# !pip install tidy3d # if needed, install tidy3d in a notebook by uncommenting this line

# import the tidy3d package and configure it with your API key
import numpy as np
import tidy3d as td
import tidy3d.web as web
# web.configure("YOUR API KEY") # if authentication needed, uncomment this line and paste your API key here

# set up global parameters of simulation ( speed of light / wavelength in micron )
freq0 = td.C_0 / 0.75

# create structure - a box centered at 0, 0, 0 with a size of 1.5 micron and permittivity of 2
square = td.Structure(
    geometry=td.Box(center=(0, 0, 0), size=(1.5, 1.5, 1.5)),
    medium=td.Medium(permittivity=2.0)
)

# create source - A point dipole source with frequency freq0 on the left side of the domain
source = td.PointDipole(
    center=(-1.5, 0, 0),
    source_time=td.GaussianPulse(freq0=freq0, fwidth=freq0 / 10.0),
    polarization="Ey",
)

# create monitor - Measures electromagnetic fields within the entire domain at z=0
monitor = td.FieldMonitor(
    size=(td.inf, td.inf, 0),
    freqs=[freq0],
    name="fields",
    colocate=True,
)

# Initialize simulation - Combine all objects together into a single specification to run
sim = td.Simulation(
    size=(4, 3, 3),
    grid_spec=td.GridSpec.auto(min_steps_per_wvl=25),
    structures=[square],
    sources=[source],
    monitors=[monitor],
    run_time=120/freq0,
)

print(f"simulation grid is shaped {sim.grid.num_cells} for {int(np.prod(sim.grid.num_cells)/1e6)} million cells.")

# run simulation through the cloud and plot the field data computed by the solver and stored in the monitor
data = td.web.run(sim, task_name="quickstart", path="data/data.hdf5", verbose=True)
ax = data.plot_field("fields", "Ey", z=0)

This will produce the following plot, which visualizes the electromagnetic fields on the central plane.

_images/quickstart_fields.png

You can now postprocess simulation data using the same python session, or view the results of this simulation on our web-based graphical user interface.

Further Information#

Github Repositories#

Name

Repository

Source Code

flexcompute/tidy3d

Example Notebooks

flexcompute/tidy3d-notebooks

FAQ Source Code

flexcompute/tidy3d-faq

These repositories are the a very good way to interact with the relevant tool developers. We encourage you to ask questions or request features through the โ€œDiscussionsโ€ or โ€œIssuesโ€ tabs of each repository accordingly.